#ifndef ESP01S_H
#define ESP01S_H
#include "bsp_system.h"

#define W_ENABLE 1
#define W_DISABLE 0
#define W_OK 0
#define W_ERROR 1

typedef struct
{
    uint8_t init_flag;
    uint8_t start_flag;
    uint8_t receiveDataFlag;
    uint16_t error_code;
} ML307R_TypeDef;

typedef struct
{
    uint8_t select_flag;
    uint8_t map_num_temp;
    uint8_t floor_num_temp;
    uint8_t room_num_temp;
} building_info_t;

typedef struct
{
    float remain;         // 剩余电量
    char update_time[20]; // 更新时间
    float usage;          // 用电量
    char time[20];        // 用电时间
} ML307R_Data;

typedef enum
{
    SOUTH_1 = 0,
    SOUTH_2,
    SOUTH_3,
    SOUTH_4,
    SOUTH_5,
    SOUTH_6,
    SOUTH_7,
    SOUTH_8,
    CENTER_1A,
    CENTER_1B,
    CENTER_1C,
    CENTER_1D,
    EAST_20,
    EAST_21,
    EAST_22,
    EAST_23,
} BUILDING_MAP_TYPE;

/*数据显示*/
float ml307r_get_remain(void);      // 获取剩余电量
float ml307r_get_usage(void);       // 获取用电量
char *ml307r_get_update_time(void); // 获取更新时间
char *ml307r_get_time(void);        // 获取用电时间

/*OLED显示中文楼栋辅助函数 */
char *get_building_map_index(uint8_t index);
char *get_building_map_remain_index(uint8_t index); // 获取楼号去掉第一个中文字符

/*应用API*/
int ml307r_init(void);
void ml307r_get_electricity(void *arg);
#endif
